package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.data.entity.ProjectFunction;
import com.nbsaas.boot.project.api.domain.request.ProjectFunctionRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.project.data.entity.ProjectFunction;
            import com.nbsaas.boot.project.data.entity.ProjectApp;

/**
* 请求对象转换成实体对象
*/

public class ProjectFunctionEntityConvert  implements Converter<ProjectFunction, ProjectFunctionRequest> {

    @Override
    public ProjectFunction convert(ProjectFunctionRequest source) {
        ProjectFunction result = new ProjectFunction();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                    ProjectFunction parent =new ProjectFunction();
                    parent.setId(source.getParent());
                    result.setParent(parent);
                    }
                    if(source.getProjectApp()!=null){
                    ProjectApp projectApp =new ProjectApp();
                    projectApp.setId(source.getProjectApp());
                    result.setProjectApp(projectApp);
                    }
        return result;
    }
}

